﻿using System;
using System.Collections.Generic;
using System.Text;

using RaisingStudio.Data;
using RaisingStudio.Data.Common;
using RaisingStudio.Data.Expressions;

namespace RaisingStudio.Data.Common
{
    public interface IDataSetAdapter : ITransactionManager
    {
        int DeleteByRelation(string tableName, object[] primaryKeys);
        int DeleteByRelation(string tableName, CommonCommand conditionCommand);
        int DeleteByRelation(string tableName, object[] primaryKeys, string transactionID);
        int DeleteByRelation(string tableName, CommonCommand conditionCommand, string transactionID);
   
        int ExecuteNonQueryCommand(CommonCommand commonCommand, string transactionID);
        int ExecuteNonQueryCommand(CommonCommand commonCommand);
        System.Data.IDataReader ExecuteReaderCommand(CommonCommand commonCommand);
        System.Data.IDataReader ExecuteReaderCommand(CommonCommand commonCommand, string transactionID);
        object ExecuteScalarCommand(CommonCommand commonCommand, string transactionID);
        object ExecuteScalarCommand(CommonCommand commonCommand);
  
        int Fill(System.Data.DataSet dataSet, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
        int Fill(System.Data.DataSet dataSet, string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        int Fill(System.Data.DataSet dataSet, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        int Fill(System.Data.DataSet dataSet, string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
        int Fill(System.Data.DataSet dataSet, string transactionID);
        int Fill(System.Data.DataSet dataSet, string[] tableNames, string transactionID);
        int Fill(System.Data.DataSet dataSet, string[] tableNames);
        int Fill(System.Data.DataSet dataSet);
   
        int FillByRelation(System.Data.DataSet dataSet, string tableName, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, CommonCommand conditionCommand, bool viewMode);
        int FillByRelation(System.Data.DataSet dataSet, string tableName, object[] primaryKeys, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, bool viewMode);
        int FillByRelation(System.Data.DataSet dataSet, string tableName, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, CommonCommand conditionCommand, bool viewMode, string transactionID);
        int FillByRelation(System.Data.DataSet dataSet, string tableName, object[] primaryKeys, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, bool viewMode, string transactionID);
     
        System.Data.DataSet GetData(string[] tableNames, string transactionID);
        System.Data.DataSet GetData(string transactionID);
        System.Data.DataSet GetData(System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        System.Data.DataSet GetData(string[] tableNames);
        System.Data.DataSet GetData();
        System.Data.DataSet GetData(System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
        System.Data.DataSet GetData(string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        System.Data.DataSet GetData(string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
   
        System.Data.DataSet GetDataByRelation(string tableName, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, CommonCommand conditionCommand, bool viewMode, string transactionID);
        System.Data.DataSet GetDataByRelation(string tableName, object[] primaryKeys, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, bool viewMode, string transactionID);
        System.Data.DataSet GetDataByRelation(string tableName, object[] primaryKeys, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, bool viewMode);
        System.Data.DataSet GetDataByRelation(string tableName, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, CommonCommand conditionCommand, bool viewMode);
 
        int Update(System.Data.DataSet dataSet, string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        int Update(System.Data.DataSet dataSet, string transactionID);
        int Update(System.Data.DataSet dataSet, string[] tableNames, string transactionID);
        int Update(System.Data.DataSet dataSet, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary);
        int Update(System.Data.DataSet dataSet, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
        int Update(System.Data.DataSet dataSet, string[] tableNames);
        int Update(System.Data.DataSet dataSet);
        int Update(System.Data.DataSet dataSet, string[] tableNames, System.Collections.Generic.Dictionary<string, string[]> columnNamesDictionary, string transactionID);
        
        #region Extension Functions
        #region Common Methods
        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(TableExpression[] tableExpressions);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, TableExpression[] tableExpressions);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, TableExpression[] tableExpressions);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetDataByRelation(RaisingStudio.Data.Expressions.TableExpression tableExpression, object[] primaryKeys, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelation(System.Data.DataSet dataSet, TableExpression tableExpression, object[] primaryKeys, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelationByPrimaryKey(System.Data.DataSet dataSet, TableExpression tableExpression, object primaryKey, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode);

        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="viewMode">view mode.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetDataByRelation(TableExpression tableExpression, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, ConditionExpression conditionExpression, bool viewMode);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="viewMode">view mode.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelation(System.Data.DataSet dataSet, TableExpression tableExpression, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, ConditionExpression conditionExpression, bool viewMode);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelation(TableExpression tableExpression, object[] primaryKeys);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelationByPrimaryKey(TableExpression tableExpression, object primaryKey);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelation(TableExpression tableExpression, ConditionExpression conditionExpression);
        #endregion
        #region Transaction
        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(TableExpression[] tableExpressions, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, TableExpression[] tableExpressions, string transactionID);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, TableExpression[] tableExpressions, string transactionID);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetData(TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int Fill(System.Data.DataSet dataSet, TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);

        /// <summary>
        /// Update dataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpressions">An array of table expression.</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int Update(System.Data.DataSet dataSet, TableExpression[] tableExpressions, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, string transactionID);


        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetDataByRelation(RaisingStudio.Data.Expressions.TableExpression tableExpression, object[] primaryKeys, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelation(System.Data.DataSet dataSet, TableExpression tableExpression, object[] primaryKeys, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="viewMode">view mode.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelationByPrimaryKey(System.Data.DataSet dataSet, TableExpression tableExpression, object primaryKey, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, bool viewMode, string transactionID);

        /// <summary>
        /// Gets dataset.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="viewMode">view mode.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>dataset.</returns>
        System.Data.DataSet GetDataByRelation(TableExpression tableExpression, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, ConditionExpression conditionExpression, bool viewMode, string transactionID);

        /// <summary>
        /// FillDataset.
        /// </summary>
        /// <param name="dataSet">dataset.</param>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="columnExpressionsDictionary">dictionary of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="viewMode">view mode.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. </returns>
        int FillByRelation(System.Data.DataSet dataSet, TableExpression tableExpression, Dictionary<RaisingStudio.Data.Expressions.TableExpression, RaisingStudio.Data.Expressions.ColumnExpression[]> columnExpressionsDictionary, ConditionExpression conditionExpression, bool viewMode, string transactionID);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelation(TableExpression tableExpression, object[] primaryKeys, string transactionID);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelationByPrimaryKey(TableExpression tableExpression, object primaryKey, string transactionID);

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="tableExpression">table name expression</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        int DeleteByRelation(TableExpression tableExpression, ConditionExpression conditionExpression, string transactionID);
        #endregion
        #endregion
    }
}
